refactor: decouple routingServer into BGPWatcher, BGPHandler and routingHandler #800
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
routingServerwith mixed responsibilities:routingServerinto three focused components:Summary of Components:
1. BGPWatcher (
watchers/bgp_watcher.go)BGPHandler)BGPHandler2. BGPHandler (
felix/routing/bgp_handler.go)RoutingHandler):Connectivityevents)SRv6Policyevents)ConnectivityAdded- Route learned from BGP peerConnectivityDeleted- Route withdrawn by BGP peerSRv6PolicyAdded- SRv6 tunnel route learnedSRv6PolicyDeleted- SRv6 tunnel route withdrawn3. RoutingHandler (
felix/routing/routing_handler.go)BGPHandler):BGPPathevents →BGPHandler→GoBGP server)BGPPathAdded- Local prefix to announceBGPPathDeleted- Local prefix to withdraw4. PeerHandler (
felix/routing/peer_handler.go)BGPHandler)BGPPeerevents →BGPHandler→GoBGP server)BGPPeerAdded- New peer to configureBGPPeerUpdated- Peer configuration changedBGPPeerDeleted- Peer to remove5. ConnectivityHandler (
felix/connectivity/connectivity_handler.go)Event-Driven Architecture
The refactoring introduces a clean event-driven pattern:
Event Flow
All BGP related events now flow through Felix server's event loop:
New Events Registered
The following events are now registered in
felix_server.goand handled inhandleFelixServerEvents():Separation of Watching vs Business Logic
Watching Logic (Observation)
Business Logic (Decision & Execution)
BGPHandler]BGPHandler]